package DeportManage;

public class Calculation {
	private int days_calculation; //the number of days
	private double weight_calculation; //the weight of parcel(kg)
	private double height_calculation; //the height of parcel
	private double width_calculation; //the width of parcel
	private double length_calculation; //the length of parcel
	/**
	 * Constructor to create an object with days, weight, height, width, length
	 * @param days int the number of days
	 * @param weight double the weight of parcel(kg)
	 * @param height double the height of parcel
	 * @param width double the width of parcel
	 * @param length double the length of parcel
	 */
	public Calculation(int days,double weight,double height, double width, double length){
		days_calculation = days;
		weight_calculation = weight;
		height_calculation = height;
		width_calculation = width;
		length_calculation = length;
	}
	/**
	 * Method to calculate the total cost of parcel collection 
	 * @return double the total fee of collecting parcel
	 */
	public double getCost(){
		double basic_price = 0; // define the basic price of parcel
		double total_cost = 0; // define the total cost of parcel
		double dimension = height_calculation + width_calculation + length_calculation;
		
		// calculate the basic price of parcel
		if(dimension <= 1.5  && weight_calculation <= 5){
			basic_price = 10;
		}
		else if(dimension <= 1.5 && weight_calculation > 5){
			basic_price = 10 + 0.08 * (weight_calculation - 5);
		}
		else if(dimension > 1.5){
			basic_price = 10 + 1.2 * (dimension - 1.5);					
		}
		
		// calculate the total cost via the number of days
		if(days_calculation >= 0 && days_calculation <= 2){
			total_cost = basic_price;
		}
		else if(days_calculation >= 3 && days_calculation <= 7){
			int extra_day = days_calculation - 2;
			total_cost = basic_price + basic_price * 0.007 * extra_day;
		}
		else if(days_calculation >= 8 && days_calculation <= 14){
			int extra_day = days_calculation - 7;//??
			total_cost = basic_price + basic_price * 0.035 + basic_price * 0.014 * extra_day;
		}
		
		//Keep two decimal places
		total_cost = (double)Math.round(total_cost * 100) / 100;
		return total_cost;
	}
}